package com.example.controller;


import com.example.entity.CommoditOrder;
import com.example.service.ICommoditOrderService;
import com.example.util.Code;
import com.example.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tyhxzy
 * @since 2023-11-03
 */
@RestController
@RequestMapping("/s/commodit-order")
public class CommoditOrderController {
    @Autowired
    ICommoditOrderService service;

    //通过typecode获取对应状态
    @GetMapping("/find/{code}")
    public Result findAllByCode(@PathVariable Integer code){
        List<CommoditOrder> byTCode = service.findByTCode(code);

        if (byTCode.size()==0){
            return new Result(Code.GET_ERR,"传递值错误，无此对象");
        }
        return new Result(Code.GET_OK,byTCode,"获取对应状态列成功");
    }
    //查询商店中未存在的商品类型
    @GetMapping("/select/{store}/{code}")
    public Result findAllByCode1(@PathVariable Integer store,@PathVariable Integer code){
        return new Result(Code.GET_OK,service.selectType(store, code),"查询成功");
    }
}
